<!--
 * Created by PhpStorm.
 * 版权所有: 2019~2022 [ hhygyl ]
 * Date: 2019/6/27-15:05
 * Link: http://luckyadmin.luckyhhy.cn
 * FileName: index.html
 *-->

{include file="public/head" /}

<style>
    .layui-side {
        height: 900px !important;
    }
    .layui-side-scroll {
        width: 100%;
    }
    .layui-tree-main .layui-tree-txt {
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
        width: 290px;
    }
    .layui-tree-icon .layui-icon{
        margin-left: 0;
    }
    .layui-btn-container .layui-btn{
        margin-bottom: 30px !important;
    }
    .layui-nav-img {
        width: 26px !important;
        height: 26px !important;
    }
</style>

<body>
<!-- 正文开始 -->
<div class="layui-fluid">

    <div class="layui-row layui-col-space10">

        <!--左侧开始-->
       <div class="layui-col-md3 layui-side layui-side-child">
            <div class="layui-card">
                <div class="layui-card-header" style="font-weight: 800;">集团总部组织架构</div>
                <div class="layui-card-body layui-row layui-side-scroll">
                    <div class="demo-tree-more" id="menuLfetTree">
                    </div>
                </div>

            </div>

        </div>
        <!--左侧结束-->


        <div class="layui-col-md9">

            <!--搜索开始-->
            <div class="layui-card">
                <div class="layui-card-body layui-row ">
                    <form action="" class="layui-form" method="get" >
                        <div class="layui-form-item">

                            {:widget('forms/search',array('name','员工信息','请输入姓名或手机号'))}

                            <div class="layui-inline" style="padding-left: 20px;">
                                <button class="layui-btn icon-btn" lay-filter="search" lay-submit="">
                                    <i class="layui-icon"></i>搜索
                                </button>
                                <button class="layui-btn icon-btn layui-btn-normal"  onclick="javascript:window.location.reload();" >
                                    <i class="layui-icon layui-icon-refresh"></i> 重置
                                </button>
                            </div>

                        </div>

                    </form >
                </div>

            </div>



            <!--右侧表格开始-->
            <div class="layui-card">
                <div class="layui-card-header" style="line-height: 72px;">
                    <div class="layui-btn-container do_btn">

                        {:widget('forms/reload')}

                        <!--<a class="layui-btn layui-btn-sm layui-btn-normal" href='http://192.168.8.110:8098/bioLogin.do' target="_blank">设置门禁权限</a>-->

                    </div>
                </div>
                <div class="layui-card-body">

                    {:widget('forms/table')}

                </div>
            </div>
            <!--右侧表格结束-->

        </div>


    </div>




</div>

<!--模板-->
<script type="text/html" id="operationTpl">

    {:widget('forms/Operationbtn',array('设置电梯楼层','orderprinter'))}

</script>



{include file="public/js" /}


<script>

    layui.use(['element', 'table', 'form', 'jquery', 'laydate','lucky','tree'], function () {
        var element = layui.element;
        var form = layui.form;
        var table = layui.table;
        var $ = layui.jquery;
        var laydate = layui.laydate;
        var tree=layui.tree;
        var lucky=layui.lucky;

        form.render();

        //基本演示
        tree.render({
            elem: '#menuLfetTree'
            ,data: {$data}
            ,showCheckbox: false  //是否显示复选框
            ,id: 'demoId1'
            ,isJump: false //是否允许点击节点时弹出新窗口跳转
            ,click: function(obj){
                var data = obj.data;  //获取当前点击的节点数据
                console.log(data);
               // layer.msg('状态：'+ obj.state + '<br>节点数据：' + JSON.stringify(data));
                layui.table.reload("table_id", {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where:{department_id:data.id}
                }, 'data');
            }
        });


       // layer.load(2);
        table.render({
            elem: '#tableFilter',
            url:"{:url('user/index')}",
            //toolbar: '#toolbarDemo',
            even: true, //开启隔行背景
            id:'table_id',
            page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
            layout: ['limit', 'count', 'prev', 'page', 'next', 'skip','last'] //自定义分页布局
                //,curr: 5 //设定初始在第 5 页
                ,groups: 5 //只显示 1 个连续页码
                ,first: false //不显示首页
                ,last: false //不显示尾页
                ,limit:20
                ,limits:[20,30,40,50,60,100]
            },
           // height: 'full-100',
            text: {
                none: '暂无相关数据'
            },
            cols: [[
                // {type: 'checkbox'},
                {field: 'user_id',  title: '员工ID', align: 'center',width:110},
                {field:'avatar_origin',style:'cursor: pointer;',title:"头像", align: 'center', width:100,templet:function (d) {
                    return '<img  src="'+d.avatar_origin+'" class="layui-nav-img" alt="无图" />';
                }},
                {field: 'username', minWidth: 80, align: 'center', title: '姓名'},
                {field: 'mobile', minWidth: 140, align: 'center', title: '手机号码'},
                // {field: 'open_id', width: 300, title: 'open_id'},
                {field:'gender',title:"性别", align: 'center', width:80,templet:function (d) {
                    var gstr = '保密';
                    if(d.gender == 1){
                        gstr = '男';
                    }
                    else if (d.gender == 2){
                        gstr = '女';
                    }
                    return gstr;
                }},
                {field: 'job_title', align: 'center', minWidth: 150, title: '职务'},
                {field:'status',title:"状态", align: 'center', width:80,templet:function (d) {
                        var statusstr = '<span style="color: green">正常</span>';
                        if(d.status == 2){
                            statusstr = '<span style="color: red">离职</span>';
                        }
                        return statusstr;
                    }},
                {fixed: 'right',templet: '#operationTpl', width: 180, align: 'center', title: '操作'}
            ]],

            done: function (res) {
                layer.closeAll('loading');
                clickOpenImg();
            }
        });

        function hoverOpenImg(){
            var img_show = null; // tips提示
            $('td img').hover(function(){
                var img = "<img class='img_msg' src='"+$(this).attr('src')+"' style='width:100%;max-height: 600px;' />";
                img_show = layer.tips(img, this,{
                    tips:[2, 'rgba(41,41,41,.0)']
                    ,area: ['12%']
                });
            },function(){
                layer.close(img_show);
            });
        }

        function clickOpenImg(){
            var img_show = null; // tips提示
            $('td img').click(function(){
                var img = "<img class='img_msg' src='"+$(this).attr('src')+"' style='width:100%;max-height: 600px;' />";
                img_show = layer.open({
                    type: 1,
                    closeBtn: 1,
                    shade: false,
                    title: false, //不显示标题
                    //skin: 'layui-layer-nobg', //没有背景色
                    shadeClose: false,
                    moveType: 1,
                    //area:['50%'],
                    content: '<div style="text-align:center;">'+img+'</div>'
                });
            });
        }

        /**
         * 表格搜索
         */
        form.on('submit(search)', function (obj) {
            lucky.CreateSearch("table_id",obj.field); //查询
              return false;
           });

        /**
         * 监听单行工具操作
         */
        table.on('tool(tableFilter)', function (obj) {
            var data = obj.data;
            // console.log(JSON.stringify(data));
            // console.log(data);
            // return false;
            var _id=parseInt(data.id);
            var layEvent = obj.event;
           if(layEvent==="orderprinter"){
               var urls="/admin/user/setfloor/id/"+_id;
               lucky.CreateForm("设置"+data.username+"的电梯楼层",'55%','50%',urls,"table_id");
            }

        });


        var active = {
            add:function(){
                lucky.CreateForm("添加管理员",'60%','75%',"{:url('adminmember/AddMember')}","table_id");
            },
            del: function(){ //获取选中数据
                var checkStatus = table.checkStatus('table_id'),data = checkStatus.data;
                var num=0;
                var id=[];
                for (var i in data) {
                    num++;
                    id.push(data[i].id);
                }
                if (num<1) {
                    layer.msg("请选择一项",{time:1500});return false;
                }
                lucky.Delete_data(id,"{:url('adminmember/delete')}","table_id");
            },
            reload: function(){
                lucky.CreateReload("table_id");
            },
            move:function () {
                var checkStatus = table.checkStatus('table_id'),data = checkStatus.data;
                var num=0;
                var id=[];
                for (var i in data) {
                    num++;
                    id.push(data[i].id);
                }
                if (num<1) {
                    layer.msg("请选择一项",{time:1500});return false;
                }
                layer.msg("功能待开发",{time:1500});return false;
            }
        };

        $('.do_btn .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

</script >

</body >
</html >